﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Rapid
{
    class ResultInterpretation
    {
        const string INVALID = "Invalid";
        static RapidDataDataContext db = new RapidDataDataContext();
        public static string GetInterpretation(Test test)
        {
            switch(test.testType)
            {
                case ETest.BAR:
                case ETest.BZO:
                    if(TestResults.DicResults[ETest.ControlC1].observation != EObservation.Line)
                        return INVALID;
                    break;
 
                case ETest.THC:
                case ETest.COC:
                    if (TestResults.DicResults[ETest.ControlC2].observation != EObservation.Line)
                        return INVALID;
                    break;
 
                case ETest.OPI:
                case ETest.MET:
                    if (TestResults.DicResults[ETest.ControlC3].observation != EObservation.Line)
                        return INVALID;
                    break;

                case ETest.TCA:
                case ETest.MTD:
                    if (TestResults.DicResults[ETest.ControlC4].observation != EObservation.Line)
                        return INVALID;
                    break;

                case ETest.MDMA:
                case ETest.OXY:
                    if (TestResults.DicResults[ETest.ControlC5].observation != EObservation.Line)
                        return INVALID;
                    break;

                case ETest.AMP:
                case ETest.PCP:
                    if (TestResults.DicResults[ETest.ControlC6].observation != EObservation.Line)
                        return INVALID;
                    break;
            }

            return db.Observations.Single(ob => ob.TypeDrug == 1 && ob.ObservationType == test.observation.ToString()).Interpretation;
        }

        public static string GetInterpretationMonitoring(EObservation observation)
        {
            return db.Observations.Single(ob => ob.TypeDrug == 2 && ob.ObservationType == observation.ToString()).Interpretation;
        }

        public static string GetCommonInterpretation(EObservationCommon commonObservation)
        {
            return db.Observations.Single(ob => ob.TypeDrug == 3 && ob.ObservationType == commonObservation.ToString()).Interpretation;
        }
    }
}
